/*
 * filemanager.h
 *
 *  Created on: Nov 23, 2009
 *      Author: Wim
 */

#ifndef FILEMANAGER_H_
#define FILEMANAGER_H_

#include <Poco/File.h>
using Poco::File;

#include <Poco/Types.h>
using Poco::UInt32;

#include <string>
using std::string;

#include <exception>
using std::exception;

class FileNotFoundException : public exception {};


class FileManager {
	public:
		/**
		 * Creates a FileManager and optionally sets it with the specified file directory
		 * @param filedir Directory that will be searched for files
		 */
		FileManager(string filedir = "");

		virtual ~FileManager();

		/**
		 * Adds a file to the manager. If the location of the content is already in the working directory with the given name, nothing happens.
		 *
		 * @param filename The name to give to the file.
		 * @param file Where the content of the file is located.
		 */
		void addFile(string filename, File file);

		/**
		 * Remove a file from the manager
		 */
		void removeFile(string filename);

		/**
		 * Searches for the file in the catalog. Throws an FileNotFoundException of the filename is not found.
		 *
		 * @param filename The name of the file.
		 */
		File searchFile(string filename);

		/**
		 * Calculates the hash of the filename
		 * @param file The file you're curious about
		 * @param filename The filename you want to hash
		 */
		static UInt32 hash(File file);
		static UInt32 hash(string filename);

	private:
		File _filedir;
};

#endif /* FILEMANAGER_H_ */
